<template>
  <div class="dashBoard-topBox">
    <div class="title">
      常用<img src="~@/assets/img/setting.png" alt="" @click="setting" />
    </div>
    <div class="operation">
      <div
        class="group"
        v-for="(item, index) in menus"
        :key="index"
        @click="goNextPage(item)"
        :class="index > 3 ? 'grouped' : ''"
      >
        <img
          :src="require(`../../assets/home/img/${item.attachment}`)"
          class="top"
          alt=""
          v-if="item.type == 'apply'"
        />
        <span v-else>
          <img
            class="top"
            :src="`${apiBaseUrlDownload}jksaas-mgt/mgt${item.attachment}`"
            v-if="item.attachment"
          />
          <img src="~@/assets/home/img/2.png" class="top" alt="" v-else />
        </span>
        <span class="bottom">{{ item.name }}</span>
      </div>
    </div>
  </div>
</template>
<script>
import { produceAxios, getAction } from "@/api/manage";
import { apiBaseUrlDownload } from "@/utils/request";
import { LING_YANG_ROLE_TYPE } from "@/store/mutation-types";
export default {
  created() {},
  props: {
    formdata: {
      type: Object,
      default() {
        return {};
      },
    },
    // menus: Array
  },
  data() {
    return {
      apiBaseUrlDownload,
      menus: [
        {
          name: "待我审批",
          number: "",
          applyType: "waiterDeal",
        },
        {
          name: "已审批",
          number: "",
          applyType: "alreadyDeal",
        },
        {
          name: "已发起",
          number: "",
          applyType: "alreadyLaunch",
        },
        {
          name: "我收到的",
          number: "",
          applyType: "copyToMe",
        },
        {
          name: "我收到的",
          number: "",
          applyType: "copyToMe",
        },
        {
          name: "我收到的",
          number: "",
          applyType: "copyToMe",
        },
      ],
    };
  },

  created() {
    this.menus = [];
    let antelopeFlag = this.$ls.get(LING_YANG_ROLE_TYPE);
    let params = {
      useScope: "app",
    };
    if (antelopeFlag) {
      params.antelopeFlag = antelopeFlag;
    }
    getAction("/sys/home/queryMyself", params).then((res) => {
      this.menus = res.result;
    });
  },
  methods: {
    goNextPage(item) {
      if (item.path == "/inventoryOrder/warehousingTask/warehousingTaskForm") {
        item.path = "/warehousingTaskForm";
        item.name = "新建入库任务";
      }

      if (item.path == "/inventoryOrder/warehouseWarrant/warehouseWarrantForm") {
        item.path = "/warehouseWarrantForm";
        item.name = "新建入库单";
      }

      if (item.path == "/inventoryCheck/inventoryCheckOrderForm") {
        item.path = "/inventoryRulesForm";
        item.name = "盘点规则";
      }

      if (item.path == "/inventoryCheck/inventoryOverTopForm") {
        item.path = "/inventoryOverTopForm";
        item.name = "新建盘盈单";
      }

      if (item.path == "/inventoryCheck/inventoryLossForm") {
        item.path = "/inventoryLossForm";
        item.name = "新建盘亏单";
      }



      let pathUrl = item.path;
      let paramsObj = {
        navTitle: item.name,
        applyType: item.type,
      };
      this.$router.push({
        path: pathUrl,
        query: paramsObj,
      });
    },
    setting() {
      this.$router.push("/commonSettings");
    },
  },
};
</script>

<style lang="scss" scoped>
.dashBoard-topBox {
  background: #ffffff;
  margin: 20px 0 70px;
  padding: 32px;
  .title {
    height: 28px;
    font-size: 28px;
    font-family: PingFang SC;
    font-weight: 400;
    color: #888888;
    display: flex;
    justify-content: space-between;
    img {
      width: 30px;
      height: 30px;
    }
  }
  .operation:after {
    content: "";
    flex: auto;
  }
  .operation {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    flex-wrap: wrap;
    .grouped {
      margin-top: 60px;
    }
    .group {
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: left;
      width: 25%;
      padding: 0 1px;
      .top {
        width: 54px;
        height: 54px;
      }
      .bottom {
        font-size: 28px;
        font-family: PingFang SC;
        font-weight: 400;
        color: #191f25;
      }
    }
  }
}
</style>
